/**
 * Created by x on 17-7-11.
 */
angular.module('leftAvaBar',[]).component(
    'leftAvaBar',
    {
        templateUrl:'component/base/leftAvaBar/left_ava_bar.template.html',
        controller: ['$rootScope' ,'$scope', 'Enum', '$state','Api', function ($rootScope, $scope, Enum, $state,Api){

            setupLeftContent($state.current.name);


            function setupLeftContent(stateName) {
                setupLeftItems(stateName);
                setupSelectedItems(stateName);
                function setupLeftItems(stateName) {
                    if (stateName.indexOf('company.company') !== -1 || stateName === 'company') {

                        $scope.leftItemsTitles = Enum.AvailabilityTitleItems;
                    }
                }
            }
            function setupSelectedItems(stateName) {
                if(stateName === 'company.companyApartmentManage'){
                    $scope.IsApartmentMangage = true;
                    $scope.IsApartmentInfo =  false
                }else{
                    $scope.IsApartmentMangage = false;
                    $scope.IsApartmentInfo =  true
                }
            }

            $scope.toApartmentManger = function (value) {
                $state.go('company.companyApartmentManage');
            };

             $rootScope.$on('$stateChangeStart', function (event, toState, toParams, fromState, fromParams) {
                 setupSelectedItems(toState.name);
             });
        }]
    }
);
